package com.help10000.rms.ui.windows

import android.content.Context
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.amir.common.holder.CommonViewHolder
import com.amir.common.mvp.base.BasePopuWindow
import com.amir.common.mvp.presenter.BasePresenter
import com.amir.common.mvp.view.IView
import com.help10000.rms.R
import com.help10000.rms.ui.adapter.SelectOrderStatusAdapter

class SelectOrderStatusPopuWindow(context: Context?, layoutid: View, width: Int, height: Int) :
    BasePopuWindow<BasePresenter<IView?>?, IView?>(context, layoutid, width, height) {
    override fun initBindHolder(holder: CommonViewHolder) {
        val linearLayoutManager = LinearLayoutManager(mContext)
        val rv_list = holder.getView<RecyclerView>(R.id.rv_list)
        rv_list.layoutManager = linearLayoutManager
        val list = mutableListOf<String>()
        val map = mutableMapOf(
            "全部" to "2",
            "待接单" to "7",
            "待上报" to "0",
            "已上报" to "1",
            "服务中" to "3",
            "交易完成" to "4",
            "交易关闭" to "5"
        )
        list.add("全部")
        list.add("待接单")
        list.add("待上报")
        list.add("已上报")
        list.add("服务中")
        list.add("交易完成")
        list.add("交易关闭")
        val selectPickingAdapter =
            SelectOrderStatusAdapter(mContext, list, R.layout.item_select_picking)
        rv_list.adapter =selectPickingAdapter
        selectPickingAdapter.setOnItemClickListener {
            if (mOnResultListener!= null){
                mOnResultListener?.onResult(map.get(list[it]).toString(),list[it])
                dismiss();
            }
        }
    }

    var mOnResultListener : OnResultListener? = null
    interface OnResultListener {

        fun onResult(status:String,name:String)
    }
    override fun createPresenter(): BasePresenter<IView?>? {
        return null
    }
}
